package cate.game.activity.uppool.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.uppool.UpPoolActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBUpPool;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "单抽 的 请求")
public class OneDrawReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField("消耗方式，1为道具抽卡，2为元宝抽卡,3为免费抽卡")
    public int costType;

    @NoteField("阵营")
    public int campId;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        UpPoolActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<UpPoolActivity> result = single.singleDraw(costType, campId);
        if (result.ok()) {
            result.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBUpPool.ONE_DRAW_REQ;
    }
}
